import { PipeTransform, Injectable, BadRequestException } from '@nestjs/common';
import { HttpEnum } from 'src/enum/http.enum';

@Injectable()
export class FileSizeValidationPipe implements PipeTransform {
  transform(value: Express.Multer.File) {
    if (value.size > 50 * 1024 * 1024) {
      throw new BadRequestException(HttpEnum.FILE_MAX_SIZE);
    }
    return value;
  }
}
